<!--
*@Author: QWP
*@Description: 办公用品领用
*@Params pType 1 领用申请    2 领用审核
*@Date: 2024-07-08 09:51:28
-->
<template>
  <a-layout class="f-h-100 s-bg-white" id="test">
    <u-search-header>
      <u-form
        :model="searchF"
        :gutter="16"
        :elements="searchEl"
        class="f-w-auto">
        <a-col>
          <a-space>
            <u-icon-button>查询</u-icon-button>
            <u-icon-button itype="export" @click="">导出 </u-icon-button>
          </a-space>
        </a-col>
        <a-col flex="1">
          <a-row justify="end">
            <a-space>
              <template v-if="route.params.pType == '1'">
                <u-icon-button itype="add" @click="showEdit = true">新增</u-icon-button>
                <u-icon-button itype="edit" @click="showEdit = true">修改</u-icon-button>
                <u-icon-button itype="delete" @click="">删除 </u-icon-button>
              </template>
              <template v-if="route.params.pType == '2'">
                <u-icon-button itype="audit" @click="">审核</u-icon-button>
                <u-icon-button itype="close" @click="">退回</u-icon-button>
              </template>
            </a-space>
          </a-row>
        </a-col>
      </u-form>
    </u-search-header>
    <a-layout-content class="f-padding-rl24">
      <u-table
        :columns="columns"
        :data="tabData"
        v-model:pagination="pagenation"></u-table>
    </a-layout-content>
  </a-layout>

  <!-- 编辑弹窗 -->
  <Edit v-model:open="showEdit"
    wrap-class-name="full-modal"
    :title="dialogTitle" />
  
  <!-- 导入 -->
  <u-imp-data v-model:open="showImp"></u-imp-data>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, watch } from "vue";
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave} from "vue-router";
import { _IFormEl } from "@/components/common/form/interface";
import { ColProps, FormItemProps, TableColumnProps } from "ant-design-vue";
import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { numberC } from '@/util/common'
import { formatAmt, } from '@/util/format.ts'
import { depts } from '@/common/model/base'
import dayjs from "dayjs";
import Edit from './Edit.vue'
import { cloneDeep } from 'lodash'
const route = useRoute();
const router = useRouter();

onMounted(() => {
})

let pagenation = reactive({
  total: 0,
  current: 1,
  pageSize: 50,
  showTotal: total => `共 ${total} 条`
})
const searchF = reactive({
  model: {
    fwzh: "",
    fwzh1: "",
  },
});
const formItemProps: FormItemProps = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};
const searchEl: Array<_IFormEl> = [
  { label: "申请人部门", key: "rksj", element: "select", col: { span: 4 }, formItemProps: formItemProps,
    componentProps: { options: depts }
  },
  { label: "领用日期", key: "sqbm", element: "datepicker", col: { span: 4 }, formItemProps: formItemProps,},
  { label: "关键字", key: "option", element: "input", col: { span: 4 }, formItemProps: formItemProps, },
];

// 列表
const tabData = reactive([
  { a: dayjs().format("YYYY-MM-DD HH:MM:ss"), b: '应急部门', b1: '马权', b2: '应急部门', zcmc: '救援车辆', sl: '1', ggjxx: '长城炮皮卡',
    zcz: '车辆', lyrq: dayjs().format("YYYY-MM-DD HH:MM:ss"), sqyy: ''
  },
  { a: dayjs().format("YYYY-MM-DD HH:MM:ss"), b: '应急部门', b1: '马权', b2: '应急部门', zcmc: '戴尔笔记本', sl: '1', ggjxx: 'Latitude 3480',
    zcz: '电脑', lyrq: dayjs().format("YYYY-MM-DD HH:MM:ss"), sqyy: '办公'
  },
]);
let columns: Array<TableColumnProps> = reactive([
  { dataIndex: "a", title: "填报时间", width: 150 },
  { dataIndex: "b", title: "填报部门", width: 100 },
  { dataIndex: "b1", title: "申请人", width: 150 },
  { dataIndex: "b2", title: "申请人部门", width: 150 },
  { dataIndex: "zcmc", title: "资产名称", width: 150 },
  { dataIndex: "sl", title: "数量", width: 150 },
  { dataIndex: "ggjxx", title: "规格及型号", width: 150 },
  { dataIndex: "zcz", title: "资产组", width: 150 },
  { dataIndex: "lyrq", title: "领用日期", width: 150 },
  { dataIndex: "sqyy", title: "申请原因", minWidth: 150 },
]);

// 编辑
let dialogTitle = ref<string>("新增办公用品领用")
let showEdit = ref<boolean>(false)

// 导入
let showImp = ref<boolean>(false)

</script>

<style lang="scss" scoped>
.icons-list :deep(.anticon) {
  margin-right: 6px;
  font-size: 24px;
}
</style>
